<?php

use Illuminate\Support\Facades\Schema;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;

class CreatePaymentOrdersTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        Schema::create('payment_orders', function (Blueprint $table) {
            $table->increments('id');
            $table->string('out_trade_no')->default('')->comment('交易单号');
            $table->tinyInteger('type')->default('0')->comment('交易类型:0=充值订单,1=商城订单,2=洗车订单,3=洗车卡订单');
            $table->tinyInteger('pay_way')->default('0')->comment('支付类型:0=余额支付,1=微信支付,此字段只对商城订单生效');
            $table->integer('user_id')->default('0')->comment('用户ID');
            $table->integer('shop_id')->default('0')->comment('店铺ID');
            $table->decimal('amount')->default('0.00')->comment('支付金额');
            $table->tinyInteger('pay_status')->default('0')->comment('交易状态:0=待支付,1=已支付,2=已退款');
            $table->timestamp('pay_at')->nullable()->comment('支付时间');
            $table->string('transaction_id')->nullable()->comment('微信支付交易单号');
            $table->string('refund_id')->nullable()->comment('退款单号');
            $table->timestamp('refund_at')->nullable()->comment('退款时间');
            $table->text('reason')->nullable()->comment('退款原因');
            $table->json('extends')->nullable()->comment('辅助信息');
            $table->timestamps();
        });
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('payment_orders');
    }
}
